import request from '../../utils/request'


/**
 * 查询价格策略
 * 
 * @param businesstype
 * @param status
 * @param page
 * @returns {Promise.<Object>}
 */
export async function getStrategyList({businesstype, status, page}) {
    return request(apiPath.basedata + "/api/strategy", {
        method: 'get',
        data: {businesstype, status, page: page.page, size: page.size}
    });
}

/**
 * 查询价格策略详情
 * @param id
 * @returns {Promise.<Object>}
 */
export async function getStrategyById({id}) {
    return request(apiPath.basedata + "/api/strategy/" + id, {
        method: 'get'
    });
}


/**
 * 增加价格策略
 * 
 * @param businesstype
 * @param type
 * @param highprice
 * @param benefit
 * @param lowprice
 * @param status
 * @param userId
 * @returns {Promise.<Object>}
 */
export async function addStrategy({ businesstype, type, highprice, benefit, lowprice, status, userId}) {
    userId = 1;
    let creator = userId;
    return request(apiPath.basedata + "/api/strategy", {
        method: 'post',
        data: { businesstype, type, highprice, benefit, lowprice, status, userId, creator}
    });
}

/**
 * 修改价格策略
 * @param id
 * @param businesstype
 * @param type
 * @param highprice
 * @param benefit
 * @param lowprice
 * @param status
 * @param userId
 * @returns {Promise.<Object>}
 */
export async function updateStrategy({id, businesstype, type, highprice, benefit, lowprice, status, userId}) {
    userId = 1;
    let updater = userId;
    return request(apiPath.basedata + "/api/strategy", {
        method: 'put',
        data: {id, businesstype, type, highprice, benefit, lowprice, status, userId, updater}
    });
}


/**
 * 删除价格策略
 * @param id
 * @returns {Promise.<Object>}
 */
export async function deleteStrategyById({id}) {
    return request(apiPath.basedata + "/api/strategy/" + id , {
        method: 'delete'
    });
}
